package main

import (
	"bufio"
	. "fmt"
	"io"
)

// github.com/EndlessCheng/codeforces-go
func CF1426A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n, x int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &x)
		if n < 3 {
			Fprintln(out, 1)
		} else {
			Fprintln(out, (n-3)/x+2)
		}
	}
}

//func main() { CF1426A(os.Stdin, os.Stdout) }
